<template>
	<view class="superHK">
		<nav-bars bgColor="transparent" fontColor="#fff"></nav-bars>
		<view class="topBg">
			<image :src="`${baseimg}/static/superHK/topBg.png`" mode=""></image>
		</view>
		<view class="topInfo">
			<view class="userInfo">
				<image :src="headImg" mode=""></image>
				<view class="infoBox">
					<view>Hi，{{moduleType==1?'超级管家':moduleType==2?'超级政委':moduleType==3?'超级精英':''}}</view>
				</view>
			</view>
		</view>
		<view class="priceBox">
			<view class="item">
				{{moduleType==3?walletData.person_order_num:walletData.team_order_num}}
				<text>{{moduleType==3?'个人订单':'团队总订单'}}</text>
			</view>
			<view class="item" v-if="moduleType==1 || moduleType == 2" @click="toMoneyBag">
				{{walletData.team_commission}}
				<text>团队总收益</text>
			</view>
			<view class="item" @click="toMoneyBag">
				{{walletData.person_commission}}
				<text>个人收益</text>
			</view>
			<view class="item" @click="toWithdCom">
				{{walletData.cashout_amount}}
				<text>可提现</text>
			</view>
		</view>
		<view class="content">
			<!-- 订单管理 -->
			<view class="manageBox">
				<view class="tit">订单管理</view>
				<view class="manageItemBox">
					<view class="item" v-for="(item, index) in orderManage" :key="index" @click="goSkip(item.path)">
						<image :src="item.img" mode=""></image>
						{{ item.text }}
					</view>
				</view>
			</view>
			<!-- 团队管理 -->
			<view class="manageBox">
				<view class="tit">团队管理</view>
				<view class="teamManageBox">
					<view class="item" v-if="item.check" v-for="(item, index) in teamManage" :key="index"
						@click="toTeamManagePage(item)">
						<image :src="item.img" mode=""></image>
						{{ item.text }}
					</view>
				</view>
			</view>
			<!-- 客户管理 -->
			<view class="manageBox">
				<view class="tit">客户管理</view>
				<view class="teamManageBox">
					<view class="item" v-if="item.check" v-for="(item, index) in customerManage" :key="index"
						@click="goSkip(item.path)">
						<image :src="item.img" mode=""></image>
						{{ item.text }}
					</view>
				</view>
			</view>

			<!-- 操作手册 -->
			<view class="manageBox">
				<view class="tit viewAllManual">
					操作手册
					<view class="iconBtn" @click="toInformationList">
						查看全部
						<u-icon style="margin-left: 10rpx;" size="20" name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="operatioManual">
					<view class="item" @click="toInformationInfo(item.id)" v-for="(item,index) in informationList"
						:key="index">
						<image v-if="item.type==1" :src="item.media[0].path" mode="" class="info-img"></image>
						<image v-if="item.type==2" :src="item.media[0].cover" mode="" class="info-img"></image>
						<view class="infoBox">
							<view class="title omit-1">{{item.title}}</view>
							<view class="time">{{$utils.getTimeRelation(item.create_time * 1000)}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 发布动态 -->
		<view class="release" :class="openRelease ? 'releActive' : 'releActive2'">
			<view class="top"></view>
			<view class="tit">
				发布动态,
				<view class="tit2">
					让更多人了解你
					<view class="border"></view>
				</view>
			</view>
			<view class="bottomBox">
				<view class="bottom">
					<view class="imgBox" @click="toReleMsg('img')">
						<image :src="`${baseimg}/static/adminShop/upImg.png`" mode=""></image>
						图片
					</view>
					<view class="imgBox" @click="toReleMsg('video')">
						<image :src="`${baseimg}/static/adminShop/upVideo.png`" mode=""></image>
						视频
					</view>
				</view>
				<view class="iconfont" @click="openRelease = false">&#xe6a5;</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Https from '@/service/verification.js';
	import {
		GetWalletData,
		GetInformation
	} from '@/service/superHK.js'
	export default {
		data() {
			return {
				baseimg: this.$static,
				// 订单管理
				orderManage: [{
						img: `${this.$static}/static/superHK/navShop.png`,
						text: '商品',
						path: '/pages_superHK/pages/order/product/list',
					},
					{
						img: `${this.$static}/static/superHK/navProduct.png`,
						text: '产品包',
						path: '/pages_superHK/pages/order/packOrder/list',
					},
					{
						img: `${this.$static}/static/superHK/navDesginOrder.png`,
						text: '设计单',
						path: '/pages_superHK/pages/order/designer/list',
					},
					{
						img: `${this.$static}/static/superHK/navConstrOrder.png`,
						text: '装修施工',
						path: '/pages_superHK/pages/order/construction/list',
					}
				],

				// 团队管理
				teamManage: [{
						img: `${this.$static}/static/superHK/product.png`,
						text: '产品包',
						check: true,
						path: '/pagesFour/home/pages_product/product/index',
					},
					{
						img: `${this.$static}/static/superHK/promotion.png`,
						text: '活动促销',
						check: true,
						path: '/pagesFour/activity/productGoods/list',
					},
					// {
					// 	img: `${this.$static}/static/superHK/writeOff.png`,
					// 	text: '核销',
					// 	check: true,
					// 	path: '',
					// },
					// {
					// 	img: `${this.$static}/static/superHK/teamPerformance.png`,
					// 	text: '组员绩效',
					// 	check: uni.getStorageSync('moduleType') == 3 ? false : true,
					// 	path: '',
					// },
					{
						img: `${this.$static}/static/superHK/teamMembers.png`,
						text: '团队成员',
						check: uni.getStorageSync('moduleType') == 3 ? false : true,
						path: '/pages_superHK/pages/team/index',
					},
					{
						img: `${this.$static}/static/superHK/pushDynamic.png`,
						text: '发布动态',
						check: true,
						path: '',
					},
					{
						img: `${this.$static}/static/superHK/dynamic.png`,
						text: '动态管理',
						check: true,
						path: '/pagesFour/home/dynamicManage/dynamicList?moduleType=superHK',
					},
					{
						img: `${this.$static}/static/superHK/myAccount.png`,
						text: '我的账号',
						check: uni.getStorageSync('moduleType') == 3 ? false : true,
						path: '/pages/my/index/index?type=superHK',
					},
					// {
					// 	img: `${this.$static}/static/superHK/kefu.png`,
					// 	text: '客服管理',
					// 	check: uni.getStorageSync('moduleType')==3?false:true,
					// 	path: '',
					// }
				],

				// 客户管理
				customerManage: [
					// {
					// 	img: `${this.$static}/static/superHK/myCustomer.png`,
					// 	text: '我的客户',
					// 	check: true,
					// 	path: `/pages_client/pages/staff/list?moduleType=superHK&type=mine&qyUserId=${uni.getStorageSync('qyUserId')}`
					// },
					{
						img: `${this.$static}/static/superHK/teamCustomer.png`,
						text: '团队客户',
						check: uni.getStorageSync('moduleType') == 3 ? false : true,
						path: '/pages_client/pages/staff/list?moduleType=superHK'
					},
					// {
					// 	img: `${this.$static}/static/superHK/qyQr.png`,
					// 	text: '企业二维码',
					// 	check: true,
					// },
					// {
					// 	img: `${this.$static}/static/superHK/chatRecord.png`,
					// 	text: '聊天记录',
					// 	check: true,
					// },
					{
						img: `${this.$static}/static/superHK/bindCustomer.png`,
						text: '绑定客户',
						path: '/pages_superHK/pages/team/bindCustomer',
						check: uni.getStorageSync('moduleType') == 3 ? true : false,
					}
				],

				// 操作手册
				operatioManual: [],
				openRelease: false,
				moduleType: null, //超级管家类型 1-超级管家，2-超级政委，3-超级精英
				headImg: '', //个人头像
				walletData: {}, //钱包数据
				informationList: [], //资讯列表
			};
		},
		onLoad(options) {
			const that = this;
			that.moduleType = uni.getStorageSync('moduleType')
			that.headImg = options.headImg;
			that.getWalletData()
			that.getInformation()
		},
		methods: {
			// 获取钱包数据
			async getWalletData() {
				const that = this;
				let res = await GetWalletData()
				if (res.code == 1) {
					that.walletData = res.data
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				}
			},

			// 获取资讯推荐列表
			async getInformation() {
				const that = this;
				let params = {
					role: 'steward'
				}
				let res = await GetInformation(params)
				if (res.code == 1) {
					that.informationList = res.data
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				}
			},

			// 点击进入资讯详情
			toInformationInfo(id) {
				uni.navigateTo({
					url: '/pagesFour/home/information/informationInfo?information_id=' + id
				});
			},

			// 跳转到行业资讯列表
			toInformationList() {
				uni.navigateTo({
					url: '/pagesFour/home/information/informationList?moduleType=superHK'
				});
			},

			// 团队管理进入
			toTeamManagePage(item) {
				const that = this;
				if (item.text == '发布动态') {
					that.openRelease = true;
				} else if (item.text == '团队成员') {
					uni.navigateTo({
						url: item.path + '?headImg=' + that.headImg
					});
				} else {
					uni.navigateTo({
						url: item.path
					});
				}
			},

			// 跳转到发布动态
			toReleMsg(type) {
				this.openRelease = false;
				uni.navigateTo({
					url: `/pagesFour/home/releMsg/releMsg?type=${type}&moduleType=superHK`
				});
			},
			goSkip(url) {
				uni.navigateTo({
					url: url
				});
			},
			toMoneyBag(){
				uni.navigateTo({
					url: '/pages_superHK/pages/moneybag/index'
				});
			},
			//提现
			toWithdCom() {
				var that = this;
				let params = {};
				// 查询云商通账户信息
				Https.GetAccountMes(params).then(res => {
					if (res.code == 1) {
						// console.log(res.data);
						// member_type 会员类型(2企业会员,3个人会员)   is_realname 是否实名(0否,1是,2实名审核中)  is_phone	 是否绑定手机(0否,1是)
						// is_sign	是否签约(0否,1是)  signContract 签约参数 
						var data = res.data;
						if (data.is_realname == 0) {
							uni.showModal({
								title: '提示',
								content: '暂时还没实名验证,是否实名验证?',
								confirmText: '确定',
								success: function(res) {
									if (res.confirm) {
										// 会员类型(2企业会员,3个人会员)
										if (data.member_type == 2) {
											console.log(123);
											uni.navigateTo({
												url: '/pages_Verification/verification/select/certificate'
											});
											return;
										}
										if (data.member_type == 3) {
											console.log(456);
											uni.navigateTo({
												url: '/pages_Verification/verification/personal/personal'
											});
											return;
										}
									}
								}
							});
							return;
						}
						if (data.is_realname == 1) {
							if (data.is_phone == 0) {
								uni.showModal({
									title: '提示',
									content: '暂时还没绑定手机号,是否绑定?',
									confirmText: '确定',
									success: function(res) {
										if (res.confirm) {
											uni.navigateTo({
												url: '/pages_Verification/verification/bindPhone/BindPhone'
											});
										}
									}
								});
							} else if (data.is_sign == 0) {
								uni.showModal({
									title: '提示',
									content: '需要完善支付信息,是否继续?',
									confirmText: '确定',
									success: function(res) {
										if (res.confirm) {
											uni.navigateToMiniProgram({
												appId: 'wxc46c6d2eed27ca0a', //通商云平台账户小程序appId
												path: 'pages/merchantAddress/merchantAddress',
												extraData: {
													// 测试环境地址：url=https://test.allinpay.com/yungateway/member/signContract.html?
													// 生产环境地址：url=https://fintech.allinpay.com/yungateway/member/signContract.html?
													// targetUrl: 'https://test.allinpay.com/yungateway/member/signContract.html?' + data.signContract.data.param //商户拼接的请求报文
													targetUrl: data.signContract
												},
												envVersion: 'release', //develop 开发版  trial 体验版  release 正式版
												success(res) {
													// 打开成功
													console.log(res);
												}
											});
										}
									}
								});
							} else if (data.is_phone == 1 && data.is_sign == 1) {
								
								uni.navigateTo({
									url: `/pagesOne/distri/withdCom/withdCom?level=${2}&allCanPrice=${this.walletData.cashout_amount}`
								})
							}
							return;
						}
						if (data.is_realname == 2) {
							if (data.member_type == 3) {
								// 个人
								uni.navigateTo({
									url: '/pages_Verification/verification/status/status?isPersonal=true&status=0&isIndex=true'
								});
							} else if (data.member_type == 2) {
								// 企业
								uni.navigateTo({
									url: '/pages_Verification/verification/status/status?isPersonal=false&status=0&isIndex=true'
								});
							}
							return;
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},
		}
	};
</script>

<style lang="less" scoped>
	.superHK {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.topBg {
			width: 100%;
			height: 540rpx;
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.topInfo {
			padding: 40rpx 24rpx 0;

			.userInfo {
				color: #fff;
				display: flex;
				align-items: center;

				image {
					width: 108rpx;
					height: 108rpx;
					border-radius: 50%;
					background-color: #ccc;
					border: 2rpx solid #fff;
				}

				.infoBox {
					font: 500 36rpx/50rpx PingFang SC;
					margin-left: 30rpx;

					.editUser {
						display: inline-block;
						padding: 3rpx 16rpx;
						font: 500 22rpx/30rpx PingFang SC;
						color: rgba(255, 255, 255, 0.6);
						background-color: rgba(255, 255, 255, 0.1);
						border-radius: 28rpx;
					}
				}
			}
		}

		.priceBox {
			padding: 52rpx 30rpx 36rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.item {
				display: flex;
				flex-direction: column;
				align-items: center;
				font: 500 38rpx/46rpx Roboto;
				color: #fff;

				text {
					font: 500 22rpx/30rpx Roboto;
					color: rgba(255, 255, 255, 0.4);
				}
			}
		}

		.content {
			padding: 0 24rpx 30rpx;

			.manageBox {
				background-color: #fff;
				border-radius: 16rpx;
				padding: 26rpx 0 35rpx;
				margin-bottom: 24rpx;

				.tit {
					font: bold 28rpx/40rpx PingFang SC;
					color: #252525;
					padding: 0 24rpx;
				}

				// 订单管理
				.manageItemBox {
					margin-top: 25rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;

					.item {
						image {
							width: 84rpx;
							height: 84rpx;
							margin-bottom: 9rpx;
						}

						text-align: center;
						font: 500 24rpx/33rpx PingFang SC;
						color: #717171;
					}
				}

				// 团队管理
				.teamManageBox {
					display: grid;
					grid-template-columns: repeat(4, 1fr);
					grid-gap: 0.5rem;

					image {
						width: 50rpx;
						height: 50rpx;
						margin-bottom: 20rpx;
					}

					.item {
						display: flex;
						flex-direction: column;
						align-items: center;
						font: 500 24rpx/33rpx PingFang SC;
						color: #717171;
						margin-top: 48rpx;
					}
				}

				// 操作手册
				.viewAllManual {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.iconBtn {
						color: #a6a6a6;
						display: flex;
						align-items: center;
					}
				}

				.operatioManual {
					padding: 0 24rpx;

					.item {
						display: flex;
						align-items: center;
						padding: 29rpx 0;
						border-bottom: 2rpx solid #dfdfdf;

						image {
							width: 164rpx;
							height: 164rpx;
							border-radius: 12rpx;
							// background-color: #ccc;
							margin-right: 25rpx;
							flex-shrink: 0;
						}

						.infoBox {
							.title {
								width: 450rpx;
								font: bold 32rpx/45rpx PingFang SC;
								color: #252525;
							}

							.time {
								font: 500 22rpx/30rpx PingFang SC;
								color: #717171;
								margin-top: 75rpx;
							}
						}
					}
				}
			}
		}

		// 发布动态
		.release {
			width: 100%;
			height: 100%;
			position: fixed !important;
			top: -100%;
			left: 0;
			z-index: 99999;
			display: flex;
			transition: 0.5s;
			flex-direction: column;
			justify-content: space-between;
			background-color: rgba(255, 255, 255, 1);

			.top {
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				z-index: -1;
				left: 0;
				background: linear-gradient(180deg, #ccc 0%, #fff 100%);
			}

			.tit {
				font: 500 46rpx/76rpx PingFang SC;
				color: #0a0605;
				margin-top: 272rpx;
				padding-left: 60rpx;

				.tit2 {
					position: relative;

					.border {
						width: 184rpx;
						height: 10rpx;
						background-color: #ebb964;
						position: absolute;
						left: 0;
						bottom: 20rpx;
						z-index: -1;
					}
				}
			}

			.bottomBox {
				margin-bottom: 138rpx;

				.bottom {
					display: flex;
					justify-content: space-around;
					align-items: center;

					.imgBox {
						display: flex;
						flex-direction: column;
						align-items: center;

						image {
							width: 168rpx;
							height: 136rpx;
						}

						font: 500 26rpx/20rpx PingFang SC;
						color: #0a0605;
					}
				}

				.iconfont {
					margin-top: 140rpx;
					font-size: 50rpx;
					text-align: center;
				}
			}
		}

		.releActive {
			top: 0rpx;
		}
	}
</style>
